package org.finney.interceptors;

import java.util.HashMap;
import java.util.Map;

import org.junit.Assert;
import org.junit.Test;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.ActionProxyFactory;
import com.opensymphony.xwork2.DefaultActionProxyFactory;
import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.dispatcher.mapper.ActionMapping;

import org.apache.struts2.impl.StrutsActionProxyFactory;
import org.finneyfill.FillAction;

public class HeaderInterceptorIntegrationTest {

	@Test
	public void testDoesNotAllowMethodInvocations() {

		// this does not run yet...
		
		Map params = new HashMap();
	    params.put("@java.lang.System@exit(1).dummy", "dumb value");

	    HashMap extraContext = new HashMap();
	    extraContext.put(ActionContext.PARAMETERS, params);

	    try {
	        ActionProxy proxy = new StrutsActionProxyFactory().
	               createActionProxy("", "FillTime", extraContext);
	        Assert.assertEquals(Action.SUCCESS, proxy.execute());

	        FillAction action = (FillAction) proxy.getAction();
	        action.execute();

	    } catch (Exception e) {
	        e.printStackTrace();
	        Assert.fail();
	    }
	}
	
}
